﻿using MediatR;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Infrastructure.Interfaces;
using Traceability_Management.Read.Api.Application.Command.Processiings_OneWay;
using Traceability_Management.Read.Api.Application.Command.Processiings_ThreeWay;
using Traceability_Management.Read.Api.Application.Command.Processiings_TwoWay;

namespace Traceability_Management.Read.Api.Application.CommandHandler.Processiings_ThreeWay
{
    public class AddThreeWayCommandHandler : IRequestHandler<AddThreeWayCommand, ApiResult<int>>
    {
        IBaseReponsitory<Processiings_Three> Processiings_Three;

        public AddThreeWayCommandHandler(IBaseReponsitory<Processiings_Three> Processiings_Three)
        {
            this.Processiings_Three = Processiings_Three;
        }

        public async Task<ApiResult<int>> Handle(AddThreeWayCommand request, CancellationToken cancellationToken)
        {
            await Processiings_Three.AddAsync(request.Processiings_Three);
            return new ApiResult<int>
            {
                Code = ApiEnum.Success,
                Message = "添加成功",
                Data = 1
            };
        }
    }
}
